﻿
using Chain.BLL;
using System;
using System.Collections.Generic;
using System.Data;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using Wuqi.Webdiyer;

public partial class ActivityList : PageBase
{
    private Chain.BLL.Activity ActivityBll = new Chain.BLL.Activity();
    public void BindPreferentialObject()
    {
        //下拉菜单数据
        DataSet ds = new Activity().GetAwardsList();

        List<ListItem> namelist = new List<ListItem>();
        namelist.Add(new ListItem("=== 积分 ===", "0"));
        namelist.Add(new ListItem("=== 储值 ===", "0"));
        namelist.Add(new ListItem("=== 消费返利 ===", "0"));
        namelist.Add(new ListItem("=== 储值返利 ===", "0"));
        namelist.Add(new ListItem("=== 小礼品 ===", "0"));
        namelist.Add(new ListItem("=== 推广奖励 ===", "0"));
        namelist.Add(new ListItem("=== 分享奖励 ===", "0"));

        int x = 0;

        foreach (Control c in this.frmActivity.Controls)
        {
            if (c.GetType().ToString() == "System.Web.UI.HtmlControls.HtmlSelect")
            {
                ((HtmlSelect)c).Items.Add(namelist[x]);
                for (int i = 0; i < ds.Tables[x].Rows.Count; i++)
                {
                    ((HtmlSelect)c).Items.Add(new ListItem(ds.Tables[x].Rows[i]["value"].ToString(), ds.Tables[x].Rows[i]["ID"].ToString()));
                }
                x++;
            }
        }
    }

    protected void drpPageSize_SelectedIndexChanged(object sender, EventArgs e)
    {
        this.NetPagerParameter.CurrentPageIndex = 1;
        this.NetPagerParameter.PageSize = int.Parse(this.drpPageSize.SelectedValue);
        this.Get_ParameterList();
    }

    private void Get_ParameterList()
    {
        int Counts;
        DataTable dt = this.ActivityBll.GetActivityInfo(this.NetPagerParameter.PageSize, this.NetPagerParameter.CurrentPageIndex, out Counts, new string[] { "" }).Tables[0];
        this.NetPagerParameter.RecordCount = Counts;
        this.NetPagerParameter.CustomInfoHTML = string.Format("<div class=\"results\"><span>当前第{0}/{1}页 共{2}条记录 每页{3}条</span></div>", new object[] { this.NetPagerParameter.CurrentPageIndex, this.NetPagerParameter.PageCount, this.NetPagerParameter.RecordCount, this.NetPagerParameter.PageSize });
        this.gvActivityList.DataSource = dt;
        this.gvActivityList.DataBind();
        PageBase.BindSerialRepeater(this.gvActivityList, this.NetPagerParameter.PageSize * (this.NetPagerParameter.CurrentPageIndex - 1));
    }

    protected void NetPagerParameter_PageChanging(object src, PageChangingEventArgs e)
    {
        this.NetPagerParameter.CurrentPageIndex = e.NewPageIndex;
        this.Get_ParameterList();
    }

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!base.IsPostBack)
        {
            this.BindPreferentialObject();
            this.Get_ParameterList();
        }
    }
}


